package hidalgo.expenses.adapter;

import hidalgo.expenses.entities.Account;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AccountStringAdapter extends ArrayAdapter<String> {

	private Context context;
	private ArrayList<Account> accountList;

	public AccountStringAdapter(Context context, int textViewResourceId,
			ArrayList<Account> accountList) {
		super(context, textViewResourceId);
		this.context = context;
		this.accountList = accountList;

	}

	@Override
	public int getCount() {
		return accountList.size();
	}

	@Override
	public String getItem(int position) {
		return accountList.get(position).getName();
	}

	@Override
	public long getItemId(int position) {
		return accountList.get(position).getAccountId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		TextView text = new TextView(context);
		text.setText(accountList.get(position).getName());

		return text;
	}

}
